/**
 * 
 * 总的流程调度者
 * 
 * @author FengLei.You
 */
function Stage(opt){	
	this._mainLoopTime=opt.mainLoopTime;
	this._mainLoopInterval=null;
	
	this._mainLoopListener=[];
	this._stopListener=[];
	this._pauseListener=[];
	
	//0->start;1->pause;2->stop
	this.status=0;
}
Stage.prototype.start=function(){
	var _this=this;
	_this._mainLoopInterval=setInterval(
		function(){
			_this._onMainLoop();
		}
	,_this._mainLoopTime);
}
Stage.prototype.pause=function(){
	this._onPause();
}
Stage.prototype.stop=function(){
	this._onStop();
}
Stage.prototype.addMainLoopListener=function(callback){
	this._mainLoopListener.push(callback);
}
Stage.prototype.addPauseListener=function(callback){
	this._pauseListener.push(callback);
}
Stage.prototype.addStopListener=function(callback){
	this._stopListener.push(callback);
}


Stage.prototype._onMainLoop=function(){
	Me.trace('onMainLoop.call');
	if(this.status==0){
		Me.iterateCall(this._mainLoopListener);
	}
}
Stage.prototype._onStop=function(){
	this.status=2;
	Me.iterateCall(this._stopListener);
}
Stage.prototype._onPause=function(){
	this.status=1;
	Me.iterateCall(this._pauseListener);
}
